<template>
	<view class="mores">
		<view class="more-item" @tap="choosepic('album')">
			<image src="../../static/img/chatroom/picture.png"></image>
			<view class="more-title">
				图片
			</view>
		</view>
		<view class="more-item" @tap="choosepic('camera')">
			<image src="../../static/img/chatroom/camera.png" ></image>
			<view class="more-title">
				拍摄
			</view>
		</view>
		<view class="more-item" @tap="choosemap">
			<image src="../../static/img/chatroom/position.png"></image>
			<view class="more-title">
				位置
			</view>
		</view>
		<view class="more-item">
			<image src="../../static/img/chatroom/viedo.png"></image>
			<view class="more-title">
				视频
			</view>
		</view>
		<view class="more-item">
			<image src="../../static/img/chatroom/file.png"></image>
			<view class="more-title">
				文件
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "more",
		data() {
			return {};
		},
		methods: {
			choosepic(e) {
				var count = 9
				if (e !== 'album') {
					count = 1
				}
				uni.chooseImage({
					count: count, //默认9
					sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
					sourceType: [e], //从相册选择
					success: (res) =>{
						this.$emit('sendPic',res.tempFilePaths)
					}
				});
			},
			choosemap(){
				uni.chooseLocation({
					success:  (res)=> {
						const {name,address,latitude,longitude}=res
						this.$emit('map',{
							name,address,latitude,longitude
						})
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	.mores {
		display: flex;
		padding: 20rpx 32rpx;
		flex-wrap: wrap;

		.more-item {
			text-align: center;
			width: 25%;
			box-sizing: border-box;
			padding: 20rpx;

			image {
				width: 72rpx;
				height: 72rpx;
				padding: 24rpx;
				background-color: #fff;
				border-radius: 24rpx;
			}

			.more-title {
				font-size: 24rpx;
				color: rgba(39, 40, 50, .5);
				line-height: 34rpx;
			}
		}
	}
</style>
